﻿//订单号和订单金额放在订单中
public class Order {
    public int id;
    public OrderDetails details { get; set; }
    public int TotalMoney {
        get => details.product.num * details.product.unitPrice;
        private set { }
    }

    public Order(int id, OrderDetails details) {
        this.id = id;
        this.details = details;
    }

    public string ToString() {
        return $"OrderId:{id} TotalMoney:{TotalMoney}\n{details.ToString()}";
    }

    //订单号相等则订单相等
    public override bool Equals(object? obj) {
        var other = obj as Order;
        return other.id == id;
    }

    public void ChangeDetail(OrderDetails details) {
        this.details = details;
    }
}